using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;
using System.Data.SqlClient;

public partial class Community_BlogMessage : System.Web.UI.Page
{
    public string strBlogTitle = string.Empty;
    public string strDoctorName = string.Empty;
    public string strblogPostedDate = string.Empty;
    public string strBlogMessage = string.Empty;
    public string  strMessageId = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write("- " + Convert.ToString(RewriteModule.RewriteContext.Current.Params["message"]) + " - " + Request.QueryString["message"].ToString());
        
        
       
        
        if (!IsPostBack)
        {
            if (Request.QueryString["message"] !=null)
            {
            Session["BlogID"] = Convert.ToInt32(Request.QueryString["bid"]);
            //Session["BlogType"] ="2";//Convert.ToInt32(Request.QueryString["type"]);
            FillMessage();
            }

        }
       
    }


    private void FillMessage()
    {

        //Filling the grid with the messages of the topic selected in the combo
        Manager mgrobj = new Manager(true,"ConnectionString");
        string sql = "";
       

        if (Convert.ToInt32(Session["BlogType"]) == 2)
        {
            
            
                sql = "select blog.blogMessage  as BlogMessage ,blog.blogTitle as BlogTitle,doc.FName+' '+doc.MName+' '+doc.Lname ";
                sql = sql + "as Name,blog.blogPostedDate as blogPostedDate ,blog.id as blogid  from blog inner join tbl_doctors doc on  blog.doctorID=doc.id ";
                sql = sql + " where blog.ID= " + Request.QueryString["message"].ToString() + " ";

                
           
            
        }
        else
        {
            
                sql = "select blog.blogMessage  as BlogMessage ,blog.blogTitle as BlogTitle,dent.FName+' '+dent.MName+' '+dent.Lname  ";
                sql = sql + "as Name,blog.blogPostedDate as blogPostedDate ,blog.id as blogid  from blog inner join tbl_dentists dent on  blog.doctorID=dent.id ";
                sql = sql + " where   blog.ID= " + Request.QueryString["message"].ToString() + "  ";
            
        }
        
        if (sql.ToString() != "")
        {
            DataSet ds = mgrobj.ExecuteQuery(sql, "tbl");
            if (ds.Tables[0].Rows.Count > 0)
            {
                strDoctorName = ds.Tables[0].Rows[0]["Name"].ToString();
                strBlogMessage = ds.Tables[0].Rows[0]["BlogMessage"].ToString(); ;
                strblogPostedDate = ds.Tables[0].Rows[0]["blogPostedDate"].ToString(); ;
                strBlogTitle = ds.Tables[0].Rows[0]["BlogTitle"].ToString(); ;

            }

            mgrobj = null;
            
        }
    }
}
